Skip to content

feat(site): set up tracking for 404#7755

Merged
mhartington merged 1 commit intomainfrom
feat/404-tracking-for-site
Apr 2, 2026
Merged

feat(site): set up tracking for 404#7755
mhartington merged 1 commit intomainfrom
feat/404-tracking-for-site

Conversation

@aidankmcalister
Copy link
Copy Markdown
Member

@aidankmcalister aidankmcalister commented Apr 2, 2026

Summary by CodeRabbit

  • New Features
    • Implemented 404 error page tracking to capture analytics on broken links and improve user experience insights.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
blog Ready Ready Preview, Comment Apr 2, 2026 3:23pm
docs Ready Ready Preview, Comment Apr 2, 2026 3:23pm
eclipse Ready Ready Preview, Comment Apr 2, 2026 3:23pm
site Ready Ready Preview, Comment Apr 2, 2026 3:23pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 2, 2026

Walkthrough

A new 404 tracking component NotFoundTracker was created to capture PostHog analytics events when users visit the not-found page. The component is integrated into the not-found page and triggers a single event on mount with URL and pathname context.

Changes

Cohort / File(s) Summary
404 Tracking Component
apps/site/src/components/not-found-tracker.tsx
New client-side React component that captures a PostHog event (site:404_not_found) on mount, including current URL and pathname as event properties. Component renders null.
Not-Found Page Integration
apps/site/src/app/not-found.tsx
Added import and rendering of NotFoundTracker component on the not-found page. Removed unused Link import.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(site): set up tracking for 404' directly and accurately describes the main change—adding PostHog event tracking for 404 not-found pages.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@argos-ci
Copy link
Copy Markdown

argos-ci bot commented Apr 2, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Apr 2, 2026, 3:26 PM

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/site/src/components/not-found-tracker.tsx`:
- Around line 8-10: The posthog.capture call in components/not-found-tracker.tsx
is sending window.location.href (raw full URL) which may leak sensitive
query/hash data; update the payload used by
posthog.capture("site:404_not_found", ...) to omit the full href and instead use
only the safe path (window.location.pathname) or a sanitized URL built from
window.location.origin + window.location.pathname (explicitly excluding
window.location.search and window.location.hash). Locate the posthog.capture
invocation and remove or replace the $current_url field accordingly so only
pathname or the sanitized origin+pathname is sent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cab3c955-7376-463a-a9c9-00795698c273

📥 Commits

Reviewing files that changed from the base of the PR and between b7a0117 and b43d395.

📒 Files selected for processing (2)
  • apps/site/src/app/not-found.tsx
  • apps/site/src/components/not-found-tracker.tsx

Comment on lines +8 to +10
posthog.capture("site:404_not_found", {
$current_url: window.location.href,
pathname: window.location.pathname,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Avoid sending raw full URL in the 404 analytics payload.

$current_url: window.location.href can include sensitive query/hash data (tokens, emails, IDs). For a 404 signal, pathname is usually sufficient and safer.

🔧 Suggested change
   useEffect(() => {
     posthog.capture("site:404_not_found", {
-      $current_url: window.location.href,
       pathname: window.location.pathname,
     });
   }, []);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
posthog.capture("site:404_not_found", {
$current_url: window.location.href,
pathname: window.location.pathname,
useEffect(() => {
posthog.capture("site:404_not_found", {
pathname: window.location.pathname,
});
}, []);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/site/src/components/not-found-tracker.tsx` around lines 8 - 10, The
posthog.capture call in components/not-found-tracker.tsx is sending
window.location.href (raw full URL) which may leak sensitive query/hash data;
update the payload used by posthog.capture("site:404_not_found", ...) to omit
the full href and instead use only the safe path (window.location.pathname) or a
sanitized URL built from window.location.origin + window.location.pathname
(explicitly excluding window.location.search and window.location.hash). Locate
the posthog.capture invocation and remove or replace the $current_url field
accordingly so only pathname or the sanitized origin+pathname is sent.

@mhartington mhartington merged commit b919d81 into main Apr 2, 2026
16 checks passed
@mhartington mhartington deleted the feat/404-tracking-for-site branch April 2, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants